// 存储服务器拿到的Token
import { defineStore } from "pinia";
import { ref } from "vue";

const useToken = defineStore('token', () => {
    const token = ref(null)
    const updateToken = (tk) => { token.value = tk }
    const removeToken = () => token.value = null
    return { token, updateToken, removeToken }
},
    // 数据持久化存储
    {
        persist: {
            enable: true,
            strategies: [
                {
                    key: 'token',
                    storage: localStorage
                }
            ]
        }
    })
export default useToken



